﻿/**************************************************************
 * Description:
 * AITBarCodeUIAction.cs
 * Product: U9
 * Co.    : UFSoft Group
 * Author : Auto Generated 
 * version: 1.0
 **************************************************************/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UFSoft.UBF.Util.Log;
using UFSoft.UBF.UI.MD.Runtime;
using UFSoft.UBF.UI.ActionProcess;
using UFSoft.UBF.ExportService;
using System.Data;
using UFSoft.UBF.Util.DataAccess;
using UFIDA.U9.CUST.AITBarCodeBP.Proxy;
using UFIDA.U9.CUST.AITBarCodeBP;
using UFIDA.U9.CUST.AITBarCodeUI.utils;




namespace UFIDA.U9.CUST.AITBarCodeUI
{
	public partial class AITBarCodeUIAction
	{
		private void UnApproveClick_Extend(object sender, UIActionEventArgs e)
		{
			this.UnApproveClick_DefaultImpl(sender, e);
		}

		public override void OnInitAction()
		{
			base.OnInitAction();
			//提示:可注册你自己的方法到相应的事件中,如下.
			//this.CommonAction.BeforeLoad += new ActionLoadDelegate(CommonAction_BeforeLoad);
		}
		private void SaveClick_Extend(object sender, UIActionEventArgs e)
		{
			//调用模版定义的默认实现方法.如需扩展,请直接在此编程.			
			this.SaveClick_DefaultImpl(sender, e);
		}
		private void CancelClick_Extend(object sender, UIActionEventArgs e)
		{



			//调用模版定义的默认实现方法.如需扩展,请直接在此编程.			
			this.CancelClick_DefaultImpl(sender, e);
		}
		private void NewClick_Extend(object sender, UIActionEventArgs e)
		{



			//调用模版定义的默认实现方法.如需扩展,请直接在此编程.			
			this.NewClick_DefaultImpl(sender, e);
		}
		private void DeleteClick_Extend(object sender, UIActionEventArgs e)
		{



			//调用模版定义的默认实现方法.如需扩展,请直接在此编程.			
			this.DeleteClick_DefaultImpl(sender, e);
		}
		private void CopyClick_Extend(object sender, UIActionEventArgs e)
		{



			//调用模版定义的默认实现方法.如需扩展,请直接在此编程.			
			this.CopyClick_DefaultImpl(sender, e);
		}
		private void SubmitClick_Extend(object sender, UIActionEventArgs e)
		{



			//调用模版定义的默认实现方法.如需扩展,请直接在此编程.			
			this.SubmitClick_DefaultImpl(sender, e);
		}
		private void ApproveClick_Extend(object sender, UIActionEventArgs e)
		{



			//调用模版定义的默认实现方法.如需扩展,请直接在此编程.			
			this.ApproveClick_DefaultImpl(sender, e);
		}
		private void FindClick_Extend(object sender, UIActionEventArgs e)
		{



			//调用模版定义的默认实现方法.如需扩展,请直接在此编程.			
			this.FindClick_DefaultImpl(sender, e);
		}
		private void ListClick_Extend(object sender, UIActionEventArgs e)
		{
			//调用模版定义的默认实现方法.如需扩展,请直接在此编程.			
			this.ListClick_DefaultImpl(sender, e);

			//列表页面装配的URIstring 
			string ListPageID = "UFIDA.U9.CUST.AITBarCodeList";
			//列表页面接收的参数    
			//NameValueCollection param = new NameValueCollection();    
			this.CommonAction.CurrentPart.NavigatePage(ListPageID, null);
		}
		private void FirstPage_Extend(object sender, UIActionEventArgs e)
		{



			//调用模版定义的默认实现方法.如需扩展,请直接在此编程.			
			this.FirstPage_DefaultImpl(sender, e);
		}
		private void PrevPage_Extend(object sender, UIActionEventArgs e)
		{



			//调用模版定义的默认实现方法.如需扩展,请直接在此编程.			
			this.PrevPage_DefaultImpl(sender, e);
		}
		private void NextPage_Extend(object sender, UIActionEventArgs e)
		{



			//调用模版定义的默认实现方法.如需扩展,请直接在此编程.			
			this.NextPage_DefaultImpl(sender, e);
		}
		private void LastPage_Extend(object sender, UIActionEventArgs e)
		{



			//调用模版定义的默认实现方法.如需扩展,请直接在此编程.			
			this.LastPage_DefaultImpl(sender, e);
		}
		private void AttachmentClick_Extend(object sender, UIActionEventArgs e)
		{



			//调用模版定义的默认实现方法.如需扩展,请直接在此编程.			
			this.AttachmentClick_DefaultImpl(sender, e);
		}
		private void FlowClick_Extend(object sender, UIActionEventArgs e)
		{



			//调用模版定义的默认实现方法.如需扩展,请直接在此编程.			
			this.FlowClick_DefaultImpl(sender, e);
		}
		private void OutputClick_Extend(object sender, UIActionEventArgs e)
		{



			//调用模版定义的默认实现方法.如需扩展,请直接在此编程.			
			this.OutputClick_DefaultImpl(sender, e);
		}
		private void PrintClick_Extend(object sender, UIActionEventArgs e)
		{
			if (this.CurrentModel.AITBarCode.GetSelectedRecordIDs().Length == 0)
				throw new Exception("请选择记录");
			//打印设置
            IExportSettings settings = ExportServiceFactory.GetInstance().CreateExportSettingsObject();
            settings.PrintTemplateCatalogType = "UFIDA.U9.CUST.AITCode";
            settings.UserDataCallBack = new DataCallBackHandle(this.GetPrintData);
            e.Tag = settings;
            //调用模版定义的默认实现方法.如需扩展,请直接在此编程.			
            this.PrintClick_DefaultImpl(sender, e);
		}
		/// <summary>
		/// 打印确定时,获取数据
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="args"></param>
		private void GetPrintData(object sender, DataCallBackEventArgs args)
		{
			//DataSet returnDataSet = null;
			//switch (args.PrintTemplateID)
			//{
			//	//条码打印
			//	case "d92bb02a-372b-4739-8542-f0492e87d245":
			//		returnDataSet = this.GetBarCodeData(args.PrintTemplateID);
			//		break;
			//	default:
			//		break;
			//}
			args.ReturnData = this.GetBarCodeData(args.PrintTemplateID);
			UIUtils.RefreshGridUI((AITBarCodeFormWebPart)this.CurrentPart, null);
		}

        private DataSet GetBarCodeData(string PrintTemplateID)
        {
            DataSet ds = new DataSet();
			IList<IUIRecord> recs = this.CurrentModel.AITBarCode.GetSelectRecords();
            List<long> ids = new List<long>();
            foreach (IUIRecord record in recs)
            {
                ids.Add((long)record["ID"]);
            }

            PrintBarCodeProxy proxy = new PrintBarCodeProxy();
            proxy.IDS = ids;
            proxy.PrintTemplateID = PrintTemplateID;
            PrintAITBarCodeDTOData retdto = proxy.Do();
            ds = (DataSet)retdto.Data;
            return ds;
        }

        private void OnOk_Extend(object sender, UIActionEventArgs e)
		{
			//调用模版定义的默认实现方法.如需扩展,请直接在此编程.			
			this.OnOk_DefaultImpl(sender, e);
		}
		private void OnClose_Extend(object sender, UIActionEventArgs e)
		{
			//调用模版定义的默认实现方法.如需扩展,请直接在此编程.			
			this.OnClose_DefaultImpl(sender, e);
		}

		#region UBF 内置两数据处理Action
		//数据加载的扩展
		private void OnLoadData_Extend(object sender, UIActionEventArgs e)
		{
			this.OnLoadData_DefaultImpl(sender, e);
		}

		//数据收集的扩展
		private void OnDataCollect_Extend(object sender, UIActionEventArgs e)
		{
			this.OnDataCollect_DefaultImpl(sender, e);
		}
		#endregion


	}
}
